package com.gougou.quartz;

import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.impl.JobExecutionContextImpl;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * 发送消息定时任务
 * Created by EX-ZHANZHENQIANG001 on 2018-04-19.
 */
public class SendMessageJob extends QuartzJobBean {

    private JobDataMap jobDataMap;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
        //从context中获取jobDataMap
        //从jobDataMap中进行取数
        String senMessage = (String) jobDataMap.get("senMessage");
        System.out.println("任务执行中 : " + senMessage);
    }

    public JobDataMap getJobDataMap() {
        return jobDataMap;
    }

    public void setJobDataMap(JobDataMap jobDataMap) {
        this.jobDataMap = jobDataMap;
    }
}
